home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / XAMPP 1.4.14 / xampp-win32-1.4.14-installer.exe / xampp / php / pear / Net / DNS / Question.php < prev    next >
PHP Script  |  2004-03-24  |  3KB  |  95 lines

  1. <?php
  2. /*
  3.  *  License Information:
  4.  *
  5.  *    Net_DNS:  A resolver library for PHP
  6.  *    Copyright (C) 2002 Eric Kilfoil eric@ypass.net
  7.  *
  8.  *    This library is free software; you can redistribute it and/or
  9.  *    modify it under the terms of the GNU Lesser General Public
  10.  *    License as published by the Free Software Foundation; either
  11.  *    version 2.1 of the License, or (at your option) any later version.
  12.  *
  13.  *    This library is distributed in the hope that it will be useful,
  14.  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.  *    Lesser General Public License for more details.
  17.  *
  18.  *    You should have received a copy of the GNU Lesser General Public
  19.  *    License along with this library; if not, write to the Free Software
  20.  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  21.  */
  22.  
  23. /* Net_DNS_Question object definition {{{ */
  24. /**
  25.  * Builds or parses the QUESTION section of a DNS packet
  26.  *
  27.  * Builds or parses the QUESTION section of a DNS packet
  28.  *
  29.  * @package Net_DNS
  30.  */
  31. class Net_DNS_Question
  32. {
  33.     /* class variable definitions {{{ */
  34.     var $qname = NULL;
  35.     var $qtype = NULL;
  36.     var $qclass = NULL;
  37.  
  38.     /* }}} */
  39.     /* class constructor Net_DNS_Question($qname, $qtype, $qclass) {{{ */
  40.     function Net_DNS_Question($qname, $qtype, $qclass)
  41.     {
  42.         if (   is_null(Net_DNS::typesbyname($qtype))
  43.                 &&  !is_null(Net_DNS::classesbyname($qtype))
  44.                 && is_null(Net_DNS::classesbyname($qclass))
  45.                 &&  !is_null(Net_DNS::typesbyname($qclass))) {
  46.  
  47.             $t = $qtype;
  48.             $qtype = $qclass;
  49.             $qclass = $t;
  50.         }
  51.  
  52.         $this->qname = $qname;
  53.         $this->qtype = $qtype;
  54.         $this->qclass = $qclass;
  55.     }
  56.  
  57.     /* }}} */
  58.     /* Net_DNS_Question::display() {{{*/
  59.     function display()
  60.     {
  61.         echo $this->string() . "\n";
  62.     }
  63.  
  64.     /*}}}*/
  65.     /* Net_DNS_Question::string() {{{*/
  66.     function string()
  67.     {
  68.         return($this->qname . ".\t" . $this->qclass . "\t" . $this->qtype);
  69.     }
  70.  
  71.     /*}}}*/
  72.     /* Net_DNS_Question::data(&$packet, $offset) {{{*/
  73.     function data($packet, $offset)
  74.     {
  75.         $data = $packet->dn_comp($this->qname, $offset);
  76.         $data .= pack("n", Net_DNS::typesbyname(strtoupper($this->qtype)));
  77.         $data .= pack("n", Net_DNS::classesbyname(strtoupper($this->qclass)));
  78.         return($data);
  79.     }
  80.  
  81.     /*}}}*/
  82. }
  83. /* }}} */
  84. /* VIM settings{{{
  85.  * Local variables:
  86.  * tab-width: 4
  87.  * c-basic-offset: 4
  88.  * soft-stop-width: 4
  89.  * c indent on
  90.  * End:
  91.  * vim600: sw=4 ts=4 sts=4 cindent fdm=marker et
  92.  * vim<600: sw=4 ts=4
  93.  * }}} */
  94. ?>
  95.